package org.thanos.demo.config;

import io.nats.client.Connection;
import io.nats.client.Nats;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class NatsConfig {

    @Value("${spring.nats.url}")
    private String url;

    @Bean(name = "connection")
    public Connection connection() throws IOException, InterruptedException {
        return Nats.connect(url);
    }
}
